package com.gimi.cloud.jimi.dao.dao.sys;

import com.gimi.cloud.jimi.dao.common.SqlProvider;
import com.gimi.cloud.jimi.dao.myMapper.MyMapper;
import com.gimi.cloud.jimi.dto.sys.SysAuthorityDTO;
import com.gimi.cloud.jimi.entity.sys.SysAuthorityEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * Created by shazhiwei on 2017/12/18.
 */
public interface SysAuthDao extends MyMapper<SysAuthorityEntity>,BaseDao<SysAuthorityEntity,SysAuthorityDTO>{

    @Select("SELECT me_id FROM sys_authority WHERE ro_id = #{roleId};")
    List<SysAuthorityDTO> getListByRoleId(@Param(value = "roleId") Integer roleId);

    @Delete("DELETE FROM sys_authority WHERE ro_id = #{roleId};")
    Integer deleteByRoleId(@Param(value = "roleId") Integer roleId);

    @InsertProvider(type = SqlProvider.class,method = "sql")
    void saveBatch(@Param(value = "sql") String sql);
}
